/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rw.table;

import java.awt.Cursor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JTable;

/**
 *
 * @author Rene Tapia
 */
public class TableMouseMotionListener extends MouseAdapter {

    private JTable table;

    public TableMouseMotionListener(JTable table) {
        this.table = table;
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        int col = table.columnAtPoint(e.getPoint());
        int row = table.rowAtPoint(e.getPoint());

        ATableModel tableModel = (ATableModel) table.getModel();

        if (tableModel.isCellEditableByClick(row, col)) {
            table.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        } else {
            table.setCursor(Cursor.getDefaultCursor());
        }
    }
}
